var generator = require('../generator/generator');
var role = require('../model/role');

exports.addRole = function(req, res, connection) {
	var data = req.body;
	//console.log('datasasasasasas:', data);
	role.addRole(connection, data, function(rows) {
	//	console.log('rows:',rows);
		res.send(rows);
	});
};

exports.selectAll = function(req, res, connection){
	role.selectRole(connection, function(rows){
		res.send(rows);
	});
};

exports.updateRole = function(req, res, connection){
	var data = req.body;
	console.log('data:',data);
	role.updateRole(connection, data, function(rows){
		res.send(rows);
	});
};

exports.checkExist = function(req,res,connection){
 var id = req.params['id'];
 console.log('idddddd:',id);
 role.checkExist(connection, id, function(rows){
 		res.send(rows);
 });
};

exports.deleteOne = function(req,res,connection){
	var data = req.body;
	role.deleteRole(connection, data.id, function(rows){
		res.send(rows);
	});
};

exports.checkAllRole = function(req,res,connection){
	var id = req.user.id;
	role.checkAllRole(connection,id,function(rows){
		res.send(rows);
	});
};